package o;

import android.view.View;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import java.util.List;
import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public abstract class SomeTimerTask extends TimerTask {
    private static final Object ˎ = new Object();
    private static ScheduledExecutorService ॱ;
    private dyf ˋ = new dyf();

    static class e implements ThreadFactory {
        private final AtomicInteger ˏ;

        private e() {
            this.ˏ = new AtomicInteger();
        }

        public Thread newThread(Runnable runnable) {
            return new Thread(runnable, "Exposure thread #" + this.ˏ.getAndIncrement());
        }
    }

    protected abstract long ˊ();

    protected abstract int ˋ();

    protected abstract View ˏ(int i);

    protected abstract List<ExposureDetail> ˏ(int i, int i2);

    protected abstract int[] getVisibleImtePos();

    public void run() {
        if (((System.currentTimeMillis() - ˊ()) - 1000 > 0 ? 1 : 0) != 0) {
            int[] ॱ = getVisibleImtePos();
            int i = ॱ[0];
            int i2 = ॱ[1];
            if (i >= 0 && i2 >= 0) {
                if (i != i2 || ˎ(i)) {
                    if (!ˎ(i)) {
                        i++;
                    }
                    if (!ˎ(i2)) {
                        i2--;
                    }
                    List ˏ = ˏ(i, i2);
                    if (!CollectCheck.isEmpty(ˏ)) {
                        dyg ॱ2 = dyg.ॱ();
                        ॱ2.ˎ(ˏ, ˋ());
                        new dyf().ˊ(ॱ2, ˋ());
                    }
                }
            }
        }
    }

    private static ScheduledExecutorService ˎ() {
        synchronized (ˎ) {
            if (ॱ == null) {
                ScheduledExecutorService scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(4, new e());
                scheduledThreadPoolExecutor.setKeepAliveTime(10, TimeUnit.SECONDS);
                scheduledThreadPoolExecutor.allowCoreThreadTimeOut(true);
                ॱ = scheduledThreadPoolExecutor;
            }
        }
        return ॱ;
    }

    protected boolean ˎ(int i) {
        return this.ˋ.ˎ(ˏ(i));
    }

    public void ˏ() {
        ˎ().schedule(this, 1000, TimeUnit.MILLISECONDS);
    }
}
